package org.lightmtv.generator;

import internal.generator.FileMapping;
import internal.generator.GenerateUtils;

import java.io.File;
import java.util.Map;

import org.lightcommons.io.FileUtils;
import org.lightcommons.logger.Log;
import org.lightcommons.template.TemplateFactory;

public class Generator {
	public static void generate(TemplateFactory templateFactory,String templateRoot,String outputRoot,Map context,boolean overwrite,File mappingFile,String updatingFolder) throws Exception{
		String mappingText = FileUtils.readFileToString(mappingFile, "UTF-8");
		FileMapping mapping = GenerateUtils.getFileMapping(templateFactory, mappingText, context);
		GenerateUtils.generateAll(templateFactory, templateRoot, outputRoot, context, overwrite,mapping,updatingFolder);
	}
	
	public static void setLog(Log log){
		GenerateUtils.setLog(log);
	}
}
